WPF and Silverlight Edition Basic Library > Menu and ContextMenu > Menu and ContextMenu Features > Checkable Menu Items |
You can make any C1MenuItem a checkable menu item by setting its IsCheckable property to True. The value of the IsChecked property determines whether or not the menu item is checked or unchecked. By default, the IsChecked property of an item is False. When the item is clicked, the value of the IsChecked property sets to True.
You can create a group of mutually exclusive checkable items by setting the GroupName property of each item you wish to add to the group. For example, the XAML below will create a group of three mutually exclusive checkable items.
XAML |
Copy Code
|
---|---|
<c1:C1MenuItem Header="MenuItem1" IsCheckable="True" GroupName="MutuallyExclusiveGroup"/> <c1:C1MenuItem Header="MenuItem2" IsCheckable="True" GroupName="MutuallyExclusiveGroup"/> <c1:C1MenuItem Header="MenuItem3" IsCheckable="True" GroupName="MutuallyExclusiveGroup"/> |
To create checkable menu items, use one of the following methods:
Complete the following steps:
XAML Copy Code <c1:C1MenuItem Header="C1MenuItem" IsCheckable="True"/>Optional: If you want the item to be checked at run time, you can also add IsChecked="False" to the tag.
Complete the following steps:
Visual Basic Copy Code CheckableMenuItem.IsCheckable = True
C# Copy CodeCheckableMenuItem.IsCheckable = true;
Optional: If you want the item to be checked at run time, you can add the following code to the project:
Visual Basic Copy Code CheckableMenuItem.IsChecked = True
C# Copy CodeCheckableMenuItem.IsChecked = true;
Complete the following steps:
Optional: If you want the item to be checked at run time, you can also select the IsChecked check box, but doing so isn't necessary to make an item checkable.